﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;
using TB.Web.UI.WebControls;

namespace ZkSurvey.Web.Helper.Extensions
{
    public static class GridViewExExtension
    {
        public static void ShowRowNumber(this GridViewEx gv, GridViewRowEventArgs e)
        {
            ShowRowNumber(gv, e, "LtrNo");
        }

        public static void ShowRowNumber(this GridViewEx gv, GridViewRowEventArgs e, string ltrId)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                // 设置行号
                Literal ltr = (e.Row.FindControl(ltrId)) as Literal;
                if (ltr != null)
                {
                    ltr.Text = String.Format("{0}", e.Row.DataItemIndex + 1);
                }
            }
        }
    }
}